package com.person.connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnection {
	public static final String DRIVER = "com.mysql.cj.jdbc.Driver";
	public static final String URL = "jdbc:mysql://localhost:3306/personalblog?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true";
	public static final String USER = "root";
	public static final String PASSWORD = "ccit@123";
	Connection conn = null;		//�������Ӷ���
	public Connection getConn() {//��ȡ���Ӷ���
		try {
			Class.forName(DRIVER);//������������
			//��ȡ����
			conn = DriverManager.getConnection(URL, USER, PASSWORD);
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;	//�������Ӷ���
	}
	
	public boolean closeConn() {//�ر����Ӷ��󷽷�
		boolean flag = false;
		try {
			conn.close();
			flag = true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return flag;
	}
}
